<?php
/**
 *
 * 文档统计
 *
 * 如果想显示点击次数,请增加view参数,即把下面ＪＳ调用放到文档模板适当位置
 * <script src="{yeshili:ye name='phpurl'/}/count.php?view=yes&aid={yeshili:ye name='id'/}&mid={yeshili:ye name='mid'/}" language="javascript"></script>
 * 普通计数器为
 * <script src="{yeshili:ye name='phpurl'/}/count.php?aid={yeshili:ye name='id'/}&mid={yeshili:ye name='mid'/}" language="javascript"></script> 
 * @yeshili        作者:叶世立  email:ye-shi-li@qq.com
 * @version        $Id: count.php 1 20:43 2013年7月8日Z xiaoye $ 
 * @package        yeshiliCMS.Site
 * @copyright      Copyright (c) 2013 - 2020, yeshiliCMS, Inc.
 */
require_once(dirname(__FILE__)."/include/common.inc.php");
if(isset($aid)) $aid = $aid;

$maintable = '#@__archives';$idtype='typeid';$id='id';
if($aid==0) exit();
if(!empty($aid) and $a=="a")
{
    $row = $dsql->GetOne(" SELECT count(*) as c FROM `{$maintable}` WHERE {$idtype}='$aid'");
    if(is_array($row))
    {
        echo "document.write('".$row['c']."');\r\n";
    }
}
else if(!empty($aid) and $a=="b")
{
    $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET click=click+1 WHERE {$id}='$aid'");
}
else if(!empty($aid) and $a=="c")
{
    $row = $dsql->GetOne(" SELECT click FROM `{$maintable}` WHERE {$id}='$aid' ");
    if(is_array($row))
    {
        echo "document.write('".$row['click']."');\r\n";
    }
} 
exit();